from tortoise import fields, models
from tortoise.contrib.pydantic import pydantic_model_creator


class User(models.Model):
    id = fields.IntField(pk=True)
    nickname = fields.CharField(max_length=64, default='', null=False)
    email = fields.CharField(index=True, unique=True, null=False, max_length=255)
    hashed_password = fields.CharField(null=False, max_length=128)
    is_active = fields.BooleanField(default=False, null=False)
    is_superuser = fields.BooleanField(default=False, null=False)
    joined_date = fields.DatetimeField(auto_now_add=True)   # 注册时间

# UserCreate_Pydantic = pydantic_model_creator(
#     User, exclude_readonly=True, exclude=('nickname', 'is_active', 'is_superuser'))
